$(document).ready(function(){
	cw.common.getUserSession();
	var url = window.location;
	var check_no = cw.common.getQueryString(url,"check_no");
	
	if(check_no==undefined || check_no==null||check_no=='' ){
		alert("请选择一个盘点！");
		window.close();
		
		return false;
	}
	$("#CHECK_NO").val(check_no);
	
	$('#subImg').bind('click',upload);
	
})

 function upload(){
	var fi = $("#FILE").val();
	if(fi==null||fi==''||fi==undefined){
		alert("请选择上传的文件！");
		return false;
	}else{
		$("#frm").append('<input type="hidden" name="ACTION" id="ACTION" value="FILE_UP_DOWNLOAD_ACTION"/>');
	}
	var options = {
	    dataType: 'json',
    	iframe:	false,
	    success: function(data) {
	    	if(data.success){
	    		$('#subImg').bind('click',upload);
	    		var vobj=data.root.T_FILE.rs[0];
	    		alert("上传并更新成功!");
	    		window.close();
	      	}else{
	      		alert(data.errors.errmsg);
	      		$('#subImg').bind('click',upload);
	      	}
	   	}
	};
	$.ajaxSetup({contentType:'application/x-www-form-urlencoded;charset=utf-8'});
    $('#frm').ajaxSubmit(options);
}

